<template>
  <div class="app-container">
    <el-form ref="form" :model="context" label-width="120px">
<!--      <el-form-item label="标题">-->
<!--        <el-input v-model="context.title" />-->
<!--      </el-form-item>-->
      <el-form-item label="作者">
        <el-input type="name" v-model="context.name" />
      </el-form-item>
      <el-form-item label="内容">
        <el-input type="info" v-model="context.info" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary"  @click="onSubmit">新增新闻</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
import contextList from "@/views/news/ContextList.vue";
export default {
  computed: {
    contextList() {
      return contextList
    }
  },
  data() {
    return {
      context: {
        title: '',
        name: '',
        info:''
      },
    }
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url:"/context/save.do",
        method: "POST",
        data:this.context
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/contextlist");
        }
      })
    },
    checkPass() {},
    onCancel() {
      this.$message({
        message: '取消新闻的新增',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

